package tbrefund

import (
	"sync"
)

// RefundMessage 结构体
type RefundMessage struct {
	// 图片链接
	PicUrls []PicUrl `json:"pic_urls,omitempty" xml:"pic_urls>pic_url,omitempty"`
	// 留言创建时间。格式:yyyy-MM-dd HH:mm:ss
	Created string `json:"created,omitempty" xml:"created,omitempty"`
	// 留言内容。最大长度: 400个字节
	Content string `json:"content,omitempty" xml:"content,omitempty"`
	// 退款类型：NORMAL（普通留言），RETURN_GOODS_APPROVED（卖家留退货地址时留言）；如果为RETURN_GOODS_APPROVED，则退款留言中有卖家收货地址
	MessageType string `json:"message_type,omitempty" xml:"message_type,omitempty"`
	// 留言者昵称
	OwnerNick string `json:"owner_nick,omitempty" xml:"owner_nick,omitempty"`
	// 留言者身份1代表买家，2代表卖家，3代表小二
	OwnerRole string `json:"owner_role,omitempty" xml:"owner_role,omitempty"`
	// 退款编号。
	RefundId string `json:"refund_id,omitempty" xml:"refund_id,omitempty"`
	// 退款阶段，可选值：onsale（售中）, aftersale（售后）
	RefundPhase string `json:"refund_phase,omitempty" xml:"refund_phase,omitempty"`
	// 留言者openid
	OwnerOpenUid string `json:"owner_open_uid,omitempty" xml:"owner_open_uid,omitempty"`
	// 留言编号
	Id int64 `json:"id,omitempty" xml:"id,omitempty"`
	// 留言者编号
	OwnerId int64 `json:"owner_id,omitempty" xml:"owner_id,omitempty"`
}

var poolRefundMessage = sync.Pool{
	New: func() any {
		return new(RefundMessage)
	},
}

// GetRefundMessage() 从对象池中获取RefundMessage
func GetRefundMessage() *RefundMessage {
	return poolRefundMessage.Get().(*RefundMessage)
}

// ReleaseRefundMessage 释放RefundMessage
func ReleaseRefundMessage(v *RefundMessage) {
	v.PicUrls = v.PicUrls[:0]
	v.Created = ""
	v.Content = ""
	v.MessageType = ""
	v.OwnerNick = ""
	v.OwnerRole = ""
	v.RefundId = ""
	v.RefundPhase = ""
	v.OwnerOpenUid = ""
	v.Id = 0
	v.OwnerId = 0
	poolRefundMessage.Put(v)
}
